from Base.Base import Base
from selenium.webdriver.common.by import By
from time import sleep


class Page1(Base):
    #输入账号
    login_username = (By.NAME,'loginName')
    #输入密码
    login_password = (By.NAME,'roncooPwd')
    # 点击登录按钮
    login_dl = (By.XPATH, '/html/body/div/div[2]/div[1]/form/div[3]/input')


    def dl_username(self,username):
        '''
        输入账号
        :return:
        '''
        try:
            self.send_keys(self.login_username,username)
        except Exception as e:
            print(e)

    def dl_password(self,password):
        '''
        输入密码
        :return:
        '''
        try:
            self.send_keys(self.login_password,password)
        except Exception as e:
            print(e)

    def dl_dl(self):
        '''
        点击登录
        :return:
        '''
        try:
            self.click(self.login_dl)
        except Exception as e:
            print(e)

    def login(self,username,password):
        self.open_url('http://101.42.137.190:7009/roncoo-pay-web-boss/login')
        self.dl_username(username)
        sleep(3)
        self.dl_password(password)
        sleep(3)
        self.dl_dl()
        sleep(2)
        return


